package com.example.final_project.Usr.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.final_project.R;
import com.example.final_project.Usr.entry.Explan;

import java.util.List;

public class ExplanAdapter extends RecyclerView.Adapter {

    private List<Explan> explans;
    private Context context;

    public ExplanAdapter(Context context1, List<Explan> list){
        this.context = context1;
        this.explans = list;
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(context).inflate(R.layout.home_login_explan,parent,false);
        ExplanHolder explanHolder = new ExplanHolder(view);
        return explanHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        ExplanHolder explanHolder = (ExplanHolder) holder;
        explanHolder.setData(position);
    }

    @Override
    public int getItemCount() {
        return explans.size();
    }

    class ExplanHolder extends RecyclerView.ViewHolder{

        public ExplanHolder(@NonNull View itemView) {
            super(itemView);
        }

        public void setData(int position){
            Explan explan = explans.get(position);
            TextView textView = itemView.findViewById(R.id.home_login_explan);
            textView.setText(explan.getExplan());
        }

    }

}
